#include <bits/stdc++.h>

using namespace std;

class Node
{
public:
    int val;
    vector<Node *> children;

    Node() {}

    Node(int _val)
    {
        val = _val;
    }

    Node(int _val, vector<Node *> _children)
    {
        val = _val;
        children = _children;
    }
};

class Solution
{
public:
    void recursion(int &result, Node *node, int deep)
    {
        if (deep > result)
        {
            result = deep;
        }
        if (node->children.empty())
        {
            return;
        }
        int size = node->children.size();
        for (int i = 0; i < size; i++)
        {
            recursion(result, node->children[i], deep + 1);
        }
    }
    int maxDepth(Node *root)
    {
        int result = 0;
        if (root == nullptr)
        {
            return result;
        }
        recursion(result, root, 1);
        return result;
    }
};

int main()
{
    Node *root = new Node(1);
    root->children.push_back(new Node(3));
    root->children.push_back(new Node(2));
    root->children.push_back(new Node(4));
    root->children[0]->children.push_back(new Node(5));
    root->children[0]->children.push_back(new Node(6));
    Solution sol;
    cout << sol.maxDepth(root) << endl;
    return 0;
}